package com.meetingshow.meeting.actions;

import java.util.List;

import com.meetingshow.common.base.actions.BaseAction;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.meeting.uiservice.IUICityService;
import com.meetingshow.meeting.uiservice.IUIIndustryService;
import com.meetingshow.meeting.uiservice.IUIMeetingService;
import com.meetingshow.meeting.uiservice.IUIMeetingTypeService;
import com.meetingshow.meeting.uiservice.model.CityQueryParasVO;
import com.meetingshow.meeting.uiservice.model.CityVO;
import com.meetingshow.meeting.uiservice.model.IndustryQueryParasVO;
import com.meetingshow.meeting.uiservice.model.IndustryVO;
import com.meetingshow.meeting.uiservice.model.MeetingQueryParasVO;
import com.meetingshow.meeting.uiservice.model.MeetingTypeQueryParasVO;
import com.meetingshow.meeting.uiservice.model.MeetingTypeVO;
import com.meetingshow.meeting.uiservice.model.MeetingVO;
import com.meetingshow.utils.UIServiceFactory;

public class MeetingBaseAction extends BaseAction {
    /**
     * 
     */
    private static final long serialVersionUID = 8158570875945756999L;
    
    /**
     * 获取推荐会议
     * @return
     * @throws Exception
     */
    protected QueryResults<MeetingVO> getRecommendMeetings(
            String firstresultno,
            String resultspergroup
        ) throws Exception {
        MeetingQueryParasVO meetingQueryParasVO = new MeetingQueryParasVO();
        meetingQueryParasVO.setFirstresultno(firstresultno);
        meetingQueryParasVO.setResultspergroup(resultspergroup);
        return getRecommendMeetings(meetingQueryParasVO);
    }
    
    /**
     * 获取推荐会议
     * @return
     * @throws Exception
     */
    protected QueryResults<MeetingVO> getRecommendMeetings(MeetingQueryParasVO meetingQueryParasVO) throws Exception {
        meetingQueryParasVO.setRecommend_e_ne(MeetingVO.NON_RECOMMAND);
        meetingQueryParasVO.setOrderByCreateTime(MeetingQueryParasVO.DESC_ORDER);
        return getMeetings(meetingQueryParasVO);
    }

    /**
     * 获取会议
     * @return
     * @throws Exception
     */
    protected QueryResults<MeetingVO> getMeetings(
            MeetingQueryParasVO meetingQueryParasVO) throws Exception {
        IUIMeetingService uiMeetingService = UIServiceFactory
                .getUIMeetingService();
        QueryResults<MeetingVO> metQueryResults = uiMeetingService
                .queryMeeting(meetingQueryParasVO);
        return metQueryResults;
    }
    
    /**
     * 查询所有城市
     * @return
     * @throws Exception
     */
    protected List<CityVO> loadCities() throws Exception {
        CityQueryParasVO cityQueryParasVO = new CityQueryParasVO();
        IUICityService uiCityService = UIServiceFactory.getUICityService();
        QueryResults<CityVO> queryResults = uiCityService.queryCity(cityQueryParasVO);
        return queryResults.getResultList();
    }
    
    /**
     * 查询所有行业
     * @return
     * @throws Exception
     */
    protected List<IndustryVO> loadIndustries() throws Exception {
        IndustryQueryParasVO industryQueryParasVO = new IndustryQueryParasVO();
        IUIIndustryService uiIndustryService = UIServiceFactory.getUIIndustryService();
        QueryResults<IndustryVO> queryResults = uiIndustryService.queryIndustry(industryQueryParasVO);
        return queryResults.getResultList();
    }
    
    /**
     * 查询所有会议类型
     * @return
     * @throws Exception
     */
    protected List<MeetingTypeVO> loadMeetingTypes() throws Exception {
        MeetingTypeQueryParasVO meetingTypeQueryParasVO = new MeetingTypeQueryParasVO();
        IUIMeetingTypeService uiMeetingTypeService = UIServiceFactory.getUIMeetingTypeService();
        QueryResults<MeetingTypeVO> queryResults = uiMeetingTypeService.queryMeetingType(meetingTypeQueryParasVO);
        return queryResults.getResultList();
    }
    
    /**
     * Get the detail of meeting with meetingId.
     * @param meetingId
     * @return
     */
    protected MeetingVO getMeetingById(Integer meetingId) throws Exception {
        IUIMeetingService uiMeetingService = UIServiceFactory.getUIMeetingService();
        return uiMeetingService.loadMeetingById(meetingId);
    }
}
